﻿/*********************************************************************
 * @file   FITKAbstractSimplifyMesh.h
 * @brief  网格简化基类
 * @author zhangjingxuan (hiter25@outlook.com)
 * @date   2025-01-08
 *********************************************************************/
#ifndef __FITKABSTRACTSIMPLIFYMESH_H__
#define __FITKABSTRACTSIMPLIFYMESH_H__
#include "FITK2DMeshToolsAPI.h"
#include <QList>

namespace Core
{
    class FITKNode;
    class FITKPoint;
}

namespace Interface
{
    class FITKElementTri3;
}

namespace Interface
{
	/**
	 * @brief  FITKSimplifyMeshFace点结构体
	 * @author zhangjingxuan(hiter25@outlook.com)
	 * @date   2025-01-13
	 */
	struct FITKSimplifyMeshPoint
	{
		int id = 0;
		double coor[3] = { 0.0,0.0,0.0 };

	};
	/**
	 * @brief  FITKSimplifyMeshFace边结构体
	 * @author zhangjingxuan(hiter25@outlook.com)
	 * @date   2025-01-13
	 */
	struct FITKSimplifyMeshEdge
	{
		int eid = 0;
		int pid[2] = { 0 ,0 };
	};
	/**
	 * @brief  FITKSimplifyMeshFace面结构体，网格单元一定是三角形单元
	 * @author zhangjingxuan(hiter25@outlook.com)
	 * @date   2025-01-13
	 */
	struct FITKSimplifyMeshFace
	{
		int fid = 0;
		int eid[3] = { 0,0,0 };
	};
    /**
     * @brief  网格简化基类
     * @author zhangjingxuan (hiter25@outlook.com)
     * @date   2025-01-08
     */
    class FITK2DMeshToolsAPI FITKAbstractSimplifyMesh
    {
    public:
        FITKAbstractSimplifyMesh(FITKAbstractSimplifyMesh&) = delete;
        virtual ~FITKAbstractSimplifyMesh() = 0;
        /**
         * @brief    创建网格简化类对象
         * @return   FITKAbstractSimplifyMesh * 网格简化类对象
         * @author   zhangjingxuan (hiter25@outlook.com)
         * @date     2025-01-08
         */
        static FITKAbstractSimplifyMesh* createFITKSimplifyMesh();
        /**
         * @brief    创建网格拆分类对象
         * @return   FITKAbstractSimplifyMesh *
         * @author   zhangjingxuan(hiter25@outlook.com)
         * @date     2025-03-11
         */
        static FITKAbstractSimplifyMesh* createFITKSplitMesh();
		/**
		 * @brief    获取简化后网格顶点,FITKSimplifyMeshPoint类型
		 * @return   QList<FITKSimplifyMeshPoint>
		 * @author   zhangjingxuan(hiter25@outlook.com)
		 * @date     2025-01-13
		 */
		virtual QList<FITKSimplifyMeshPoint> getGeoPoint() = 0;
		/**
		 * @brief    获取简化后网格边界,FITKSimplifyMeshEdge类型
		 * @return   QList<FITKSimplifyMeshEdge>
		 * @author   zhangjingxuan(hiter25@outlook.com)
		 * @date     2025-01-13
		 */
        virtual QList<FITKSimplifyMeshEdge> getGeoBoundary() { return QList<FITKSimplifyMeshEdge>(); };
		/**
		 * @brief    获取简化后网格边,FITKSimplifyMeshEdge类型
		 * @return   QList<FITKSimplifyMeshEdge>
		 * @author   zhangjingxuan(hiter25@outlook.com)
		 * @date     2025-01-13
		 */
		virtual QList<FITKSimplifyMeshEdge> getGeoEdge() = 0;
		/**
		 * @brief    获取简化后网格单元,FITKSimplifyMeshFace类型
		 * @return   QList<FITKSimplifyMeshFace>
		 * @author   zhangjingxuan(hiter25@outlook.com)
		 * @date     2025-01-13
		 */
		virtual QList<FITKSimplifyMeshFace> getGeoFace() = 0;
		/**
		 * @brief    获取简化后网格顶点
		 * @return   QList<Core::FITKNode*> 简化后网格顶点列表
		 * @author   zhangjingxuan(hiter25@outlook.com)
		 * @date     2025-01-09
		 */
        virtual QList<Core::FITKNode*> getMeshNode() { return QList<Core::FITKNode*>(); };
		/**
		 * @brief    获取简化后网格单元
		 * @return   QList<Interface::FITKElementTri3*> 简化后网格顶点列表
		 * @author   zhangjingxuan(hiter25@outlook.com)
		 * @date     2025-01-09
		 */
        virtual QList<Interface::FITKElementTri3*> getNodeElement() { return QList<Interface::FITKElementTri3*>(); };
		/**
		 * @brief    网格简化
		 * @param[i] n_vertices 设置剩余点数量
		 * @param[i] n_faces 设置剩余面数量
		 * @return   void
		 * @author   zhangjingxuan(hiter25@outlook.com)
		 * @date     2025-01-09
		 */
        virtual void simplifyMesh(size_t n_vertices = 0, size_t n_faces = 0) {};
		/**
		 * @brief    三角形长宽比保护模块，设置三角形长宽比
		 * @param[i] ratio 三角形长宽比
		 * @return   void
		 * @author   zhangjingxuan(hiter25@outlook.com)
		 * @date     2025-01-09
		 */
        virtual void setTriAspectRatio(double ratio = 5.0) {};
		/**
		 * @brief    锁定网格边界点
		 * @return   void
		 * @author   zhangjingxuan(hiter25@outlook.com)
		 * @date     2025-01-09
		 */
        virtual void lockBoundary() {};
		/**
		 * @brief    锁定特征点，以相邻点组成两个向量的角度计算
		 * @param[i] angel1 最小角度
		 * @param[i] angel2 最大角度
		 * @return   void
		 * @author   zhangjingxuan(hiter25@outlook.com)
		 * @date     2025-01-14
		 */
        virtual void lockVertices(double angel1 = 10, double angel2 = 130) {};
		/**
		 * @brief    初始化板网格数据
		 * @param[i] meshPoints 点数据
		 * @param[i] meshFaces 面单元数据
		 * @return   bool true 初始化成功,false 初始化失败
		 * @author   zhangjingxuan(hiter25@outlook.com)
		 * @date     2025-01-09
		 */
		virtual bool initPlateMesh(const QList<Core::FITKNode*>& meshPoints, const QList<Interface::FITKElementTri3*>& meshFaces) = 0;
    protected:
        FITKAbstractSimplifyMesh() = default;
    };
}
#endif //! __FITKABSTRACTSIMPLIFYMESH_H__